package com.jimi.utils;
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;

public class PasswordUtils {
    // 配置Argon2参数：saltLength(盐长度), hashLength(哈希长度), parallelism(并行度), memory(内存成本KB), iterations(迭代次数)
    private static final Argon2PasswordEncoder encoder = new Argon2PasswordEncoder(16, 32, 2, 65536, 3);


    public static String encode(String rawPassword) {
        return encoder.encode(rawPassword);
    }


    public static boolean matches(String rawPassword, String encodedPassword) {
        return encoder.matches(rawPassword, encodedPassword);
    }
}